Run time
After columns are added and configured, rows may be added.
Adding rows
Rows may be added in several ways. Most common way is by using AddRow method.
cs
nextGrid1.AddRow();
Since AddRow method return reference to newly added row, handy Fill method may be used to set initial values for cells inside this row.
cs
nextGrid1.AddRow().Fill(
new int[] { 0, 2 },
new object[]
{
3.14,
textBox1.Text
}
);
First parameter (
array) represent column indexes, and second (also array) represent values.
There is also overloaded version of
AddRow which include count parameter. This parameter specifies number of rows to be added at the end of rows array.
cs
nextGrid1.AddRow(5); nextGrid1.AddRow(1000);
Deleting rows
After row is added, it may be deleted by calling DeleteRow method.
cs
nextGrid1.DeleteRow(2); // delete 3rd row in array nextGrid1.DeleteRow(nextGrid1.SelectedRow);
To access single row (and its properties) use nextGrid indexer.
cs
nextGrid1[rowIndex].Height = 20; // Change height of row nextGrid1[rowIndex].Visible = false; // Hide row if (nextGrid1[rowIndex].IsTopLevel) { MessageBox.Show("Top level row"); }
Cells
As soon rows are added, you may access single cells. Every cell is a object with own properties and method.
Most important property of a cell is Value:
cs
nextGrid1["MyColumnName", 4].Value = "none";